< previous page page_693 next page >

Page 693
Creating ASP Files
To create ASP files, you can use a text editor such as Notepad or a more advanced tool like Visual InterDev. In any case, your ASP file can consist of any mix of HTML and code. However, some of your pages will probably contain all code, while others will have only standard HTML. The code you write in an ASP file is script code, like the VBScript code discussed in Chapter 30, "Using VBScript."
In the following section, you create and experiment with a simple ASP file. Subsequent sections explore more involved issues in creating ASP files.
Creating a Simple ASP File
Using the same code shown earlier in Listing 31.1 and the virtual /test directory you created in the preceding section, you can create a basic ASP file and experiment with using it. Follow these steps:
1. Enter the following code in Notepad or another text editor:
<HTML>
<BODY>

The Current date and time is
<%
   Dim sTime
   sTime = Now
   Response.Write(sTime)
%>

</BODY>
</HTML>
2. Name the file THETIME.ASP and save it to the /test directory.
3. Open the file in your browser using the URL http://myserver/test/thetime.asp, where myserver is the name of your NT server or PC.
If your code does not run but is instead displayed on the screen, make sure that the file has an .ASP extension and the virtual directory has the correct permissions.
note.gif Microsoft's Web server software allows you to specify default document names (usually DEFAULT.ASP and DEFAULT.HTM). This means a user does not have to carry the URL out to the file levelfor example, http://myserver/test/ automatically displays the DEFAULT.ASP or DEFAULT.HTM file, if it exists in the /test directory. square.gif

Using Server-Side Scripting Tags
When processing an ASP file, the Web server only executes the code designated as server-side script. All other parts of an ASP file are sent directly back to the browser. In your ASP files, the server-side code can be marked in a couple of different ways:

 
< previous page page_693 next page >